package com.zhike.b2b.company.impl;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.beanutils.PropertyUtils;

import com.formbean.BrandForm;
import com.saas.sys.log.Logger;
import com.zhike.b2b.dao.DbExecute;

public class BrandExt
{
  @Resource
  DbExecute exec ;
  
  BrandForm brandBean = new BrandForm();
  Logger log = new Logger(this);
  ArrayList updArray = new ArrayList();
  ArrayList paramArray = new ArrayList();

  public List selByList(String paramString)
  {
    exec.setStrTable("brand");
    exec.setStrQuery(paramString);
    exec.setParamList(this.paramArray);
    exec.setClassName("BrandQuery");
    List data = exec.selBizQuery();
    if (data.size() <= 0)
      return null;
    return data;
  }

  public BrandForm selByInfo(String paramString)
  {
    DbExecute localDbexecute = new DbExecute();
    CommMethodMgr localcommMethodMgr = new CommMethodMgr();
    Logger localLogger = new Logger(this);
    ArrayList localArrayList = new ArrayList();
    localDbexecute.setStrTable("brand");
    localDbexecute.setStrQuery(paramString);
    localDbexecute.setParamList(this.paramArray);
    localDbexecute.setClassName("BrandQuery");
    List data = localDbexecute.selBizQuery();
    if (data.size() <= 0)
      return null;
    BrandForm localBrandForm = new BrandForm();
    Field[] arrayOfField = localBrandForm.getClass().getDeclaredFields();
    Iterator localIterator = localArrayList.iterator();
    while (localIterator.hasNext())
    {
      HashMap localHashMap = (HashMap)localIterator.next();
      for (int i = 0; i <= arrayOfField.length - 1; i++)
      {
        if (!localHashMap.containsKey(arrayOfField[i].getName()))
          continue;
        try
        {
          if (localHashMap.get(arrayOfField[i].getName()) != null)
            if (arrayOfField[i].getType().getName() == "java.lang.String")
            {
              PropertyUtils.setProperty(localBrandForm, arrayOfField[i].getName(), localHashMap.get(arrayOfField[i].getName()).toString());
            }
            else if (arrayOfField[i].getType().getName() == "java.lang.Integer")
            {
              Integer localInteger = new Integer(localHashMap.get(arrayOfField[i].getName()).toString());
              PropertyUtils.setProperty(localBrandForm, arrayOfField[i].getName(), localInteger);
            }
        }
        catch (InvocationTargetException localInvocationTargetException)
        {
          throw new RuntimeException(localInvocationTargetException);
        }
        catch (NoSuchMethodException localNoSuchMethodException)
        {
          throw new RuntimeException(localNoSuchMethodException);
        }
        catch (IllegalAccessException localIllegalAccessException)
        {
          throw new RuntimeException(localIllegalAccessException);
        }
      }
    }
    return localBrandForm;
  }

  public int selCount(String paramString)
  {
    DbExecute localDbexecute = new DbExecute();
    return 0;
  }

  public void setParam(String paramString, Object paramObject)
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("paramName", paramString);
    localHashMap.put("paramValue", paramObject);
    this.paramArray.add(localHashMap);
  }

  public ArrayList insBy(String paramString)
  {
    ArrayList localArrayList = new ArrayList();
    HashMap localHashMap = new HashMap();
    localHashMap.put("queryTable", "brand");
    localHashMap.put("queryString", paramString);
    localHashMap.put("queryVarMap", this.paramArray);
    localArrayList.add(localHashMap);
    return localArrayList;
  }

  public List selByList(String paramString, int paramInt1, int paramInt2)
  {
    DbExecute localDbexecute = new DbExecute();
    localDbexecute.setStrTable("brand");
    localDbexecute.setStrQuery(paramString);
    localDbexecute.setParamList(this.paramArray);
    localDbexecute.setClassName("BrandQuery");
    List data = localDbexecute.selBizQuery(paramInt1, paramInt2);
    if (data.size() <= 0)
      return null;
    return data;
  }
}

